package org.ting.e_commerce.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.ting.e_commerce.model.Product;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Insert("insert into product(store_id, product_name, brand, model, description, price, stock, category) " +
            "values (#{storeId}, #{productName}, #{brand}, #{model}, #{description}, #{price}, #{stock}, #{category})")
    boolean addProduct(Product product);
    @Select("select * from product where store_id = #{storeId} and product_status = #{productStatus}")
    List<Product> selectByStoreAndStatus(int storeId, String productStatus);

    @Select("select * from product where product_status = #{productStatus} limit #{index}, #{limit}")
    List<Product> selectByStatus(String productStatus, int index, int limit);

    @Select("select * from product limit #{index}, #{limit}")
    List<Product> selectAll(int index, int limit);
    @Select("select count(*) from product where product_status = #{productStatus}")
    int selectProductCountOfStatus(String productStatus);
    boolean updateById(Product product);
    @Delete("delete from product where product_id = #{productId}")
    boolean deleteById(Integer productId);

    List<Product> selectByStatusAndWords(String productStatus, List<String> words, int index, int limit);

    int selectCountOfStatusAndWords(String productStatus, List<String> words);
}
